package top.yzhao.trackdatasystem.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import top.yzhao.trackdatasystem.VO.ResultVO;
import top.yzhao.trackdatasystem.VO.TableVO;
import top.yzhao.trackdatasystem.dto.UserDTO;
import top.yzhao.trackdatasystem.service.UserService;

import java.util.List;

/**
 * User: zhaoyang
 * Date: 2020/3/13
 * Time: 15:11
 * Description: No Description
 */
@RestController
public class UserController {
    @Autowired
    private UserService userService;

    @PostMapping("/getUserList")
    public ResultVO<TableVO> getUserList(String query, int currentPage, int pageSize){
        ResultVO<TableVO> res = new ResultVO<>();

        TableVO<List<UserDTO>> tv = new TableVO<>();
        List<UserDTO> userList = userService.getUserList(query,currentPage,pageSize);
        int total = userService.getTotalUserList();
        tv.setData(userList);
        tv.setTotal(total);

        res.setData(tv);
        res.setMsg("数据请求成功");
        res.setCode(200);
        return res;
    }
}
